package com.fer.t1.client.events;

import java.util.ArrayList;
import java.util.Collection;

public class Dispatcher {

	private Collection<EventCatcher> eventCatchers;
	private static Dispatcher dispatcher;
	
	private Dispatcher() {
		eventCatchers = new ArrayList<EventCatcher>();
	}
	
	public void dispatch(Event e)
	{
		for (EventCatcher ec : eventCatchers) {
			ec.onEvent(e);
		}
	}
	
	public void registerCatcher(EventCatcher ec)
	{
		eventCatchers.add(ec);
	}
	

	public static Dispatcher get()
	{
		if (dispatcher==null)
		{
			dispatcher = new Dispatcher();
		}
		return dispatcher;
	}
	
}
